Shader "custom/begin/lambert_1"  {
	Properties {
		_Color("Color",Color) = (1.0,1.0,1.0,1.0)
	}
	SubShader {
		Pass {
		 	Tags { "LightMode" = "ForwardBase" }
			
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			
			//user define variables
			uniform float4 _Color;
			
			//unity define variables;
			uniform float4 _LightColor0;
			//_Object2World
			//_World2Object
			//_WorldSpaceLightPos0
			
			struct vetexInput {
				float4 vertex : POSITION;
				float3 normal : NORMAL;
			};

			struct vetexOutput {
				float4 pos : SV_POSITION;
				float4 col : Color;
			};

			vetexOutput vert(vetexInput v)
			{
				vetexOutput o;
				
				//vertex
				float3 normalDirection =  normalize(mul(float4(v.normal, 0.0), _World2Object).xyz) ;
				
				//light
				float3 lightDirection  = normalize( _WorldSpaceLightPos0.xyz); 
				float   atten = 1.0;
				float3 diffuseRelection
					 = atten 
					 	*  _LightColor0.xyz    
					 		*  max(0.0, dot(normalDirection, lightDirection));
				o.col =  float4(diffuseRelection * _Color.xyz, 1.0) ;
				o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
				return o;
			}

			float4 frag(vetexOutput o) : Color
			{
				return o.col;
			}
			ENDCG
		}
	}
		
	Fallback "Diffuse"
}

